home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Event;
- import java.awt.Frame;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.MediaTracker;
- import java.awt.Rectangle;
- import java.awt.image.ImageObserver;
- import java.net.MalformedURLException;
- import java.net.URL;
-
- public class Colada extends Applet implements Runnable {
- private String m_cvFile = new String();
- public String m_cvFilePath;
- public String m_bgTexture;
- public String m_targetFrame;
- private String m_status = new String("Done");
- private boolean m_check;
- private boolean m_upOrDwn;
- public ColadaDoc m_colDoc;
- private ColUrl m_curObj;
- public Thread m_colada;
- private int m_width;
- private int m_height;
- public Component m_comp = this;
- public Thread m_colDocThread;
- public Thread m_drawEngThread;
- public boolean m_colDocDone;
- public boolean m_colUpdtEnable;
- public boolean m_urlLstDone;
- public boolean firstDrawDone;
- public boolean m_dloadStoped;
- public boolean buttonisDn;
- private boolean m_panOn;
- public boolean m_stopCalled;
- public boolean m_breakDrawAll;
- private int mPosXdn;
- private int mPosYdn;
- // $FF: renamed from: a int
- private int field_0;
- private DrawEng drawEng;
- public int numlayers;
- public String layerFlags = new String();
- public int numMediaObjs;
- private Object[] mediaObs;
- private boolean didNew;
- private Image m_BackImg;
- private MediaTracker tracker;
-
- public void stop() {
- this.m_stopCalled = true;
- }
-
- public void CallMediaObjects() {
- boolean var1 = false;
- if (!this.didNew && this.m_colUpdtEnable) {
- this.mediaObs = new Object[this.numMediaObjs];
- this.didNew = true;
- ColObjIntr var2 = this.m_colDoc.m_drwLstHead;
-
- for(int var3 = 0; var2 != null; var2 = var2.getNext()) {
- if (var2.getType() == 14) {
- this.mediaObs[var3] = var2;
- ++var3;
- }
- }
- }
-
- if (this.m_colUpdtEnable && this.numMediaObjs > 0) {
- for(int var4 = 0; var4 < this.numMediaObjs; ++var4) {
- ColObj var5 = (ColObj)this.mediaObs[var4];
- var5.EventProc((Event)null);
- }
- }
-
- }
-
- public void SetZoom(float var1) {
- if (var1 >= 0.1F && var1 <= 5.0F) {
- this.m_colDoc.m_colGraphicObj.m_magChck = var1;
- ColGrph var10000 = this.m_colDoc.m_colGraphicObj;
- var10000.m_xOrg += (float)this.m_colDoc.m_colGraphicObj.m_sx / this.m_colDoc.m_colGraphicObj.m_mag - (float)this.m_colDoc.m_colGraphicObj.m_sx / this.m_colDoc.m_colGraphicObj.m_magChck;
- var10000 = this.m_colDoc.m_colGraphicObj;
- var10000.m_yOrg += (float)this.m_colDoc.m_colGraphicObj.m_sy / this.m_colDoc.m_colGraphicObj.m_mag - (float)this.m_colDoc.m_colGraphicObj.m_sy / this.m_colDoc.m_colGraphicObj.m_magChck;
- this.m_colDoc.m_colGraphicObj.m_mag = var1;
- if (this.drawEng.inDrawAll) {
- this.m_breakDrawAll = true;
- }
- }
-
- ((Component)this).repaint();
- }
-
- public void TestFunc() {
- Graphics var1 = ((Component)this).getGraphics();
- var1.setColor(Color.red);
- var1.fillRect(0, 0, 200, 200);
- }
-
- public void paint(Graphics var1) {
- Rectangle var2 = var1.getClipRect();
- if (this.m_colDoc != null && this.m_colDoc.m_colGraphicObj != null) {
- this.DrawBackGround(var1);
- if (this.firstDrawDone) {
- if (this.drawEng != null) {
- this.drawEng.DoDrawAll(var2);
- return;
- }
- } else {
- this.m_colDoc.m_colGraphicObj.drawAll(var1);
- this.firstDrawDone = true;
- }
-
- }
- }
-
- public String[][] getParameterInfo() {
- String[][] var1 = new String[][]{{"cvwFile", "String", "Canvas 5.0 Flat File to view"}};
- return var1;
- }
-
- public void destroy() {
- if (this.m_colada != null) {
- if (this.m_drawEngThread != null) {
- this.drawEng.StopWhile();
- this.drawEng = null;
- this.m_drawEngThread = null;
- }
-
- if (this.m_colDocThread != null) {
- this.m_colDoc.finalize();
- this.m_curObj = null;
- this.m_colDocThread.stop();
- this.m_colDocThread = null;
- }
-
- this.mediaObs = null;
- this.m_comp = null;
- this.m_colada.stop();
- this.m_colada = null;
- }
-
- System.gc();
- }
-
- public void SendEventToObjType(Event var1, int var2, int var3, int var4, int var5) {
- ColObjIntr var6 = this.m_colDoc.m_drwLstHead;
-
- for(boolean var7 = false; var6 != null; var6 = var6.getNext()) {
- if (var6.getType() == var2) {
- var7 = var6.EventProc(var1);
- }
-
- if (var6.getType() == var3) {
- var7 = var6.EventProc(var1);
- }
-
- if (var6.getType() == var5) {
- var7 = var6.EventProc(var1);
- }
-
- if (((ColObj)var6).cvObjNum == (long)var4) {
- var7 = var6.EventProc(var1);
- }
-
- if (var7) {
- break;
- }
- }
-
- }
-
- public boolean imageUpdate(Image var1, int var2, int var3, int var4, int var5, int var6) {
- return true;
- }
-
- public void update(Graphics var1) {
- this.paint(var1);
- }
-
- public void DrawBackGround(Graphics var1) {
- Rectangle var2 = var1.getClipRect();
- if (this.m_BackImg == null) {
- var1.setColor(this.m_colDoc.m_colGraphicObj.m_bkGrndClr);
- var1.fillRect(var2.x, var2.y, var2.width, var2.height);
- } else {
- int var3 = this.m_BackImg.getWidth((ImageObserver)null);
- int var4 = this.m_BackImg.getHeight((ImageObserver)null);
- int var5 = 1;
- int var6 = 1;
- int var7 = 0;
- int var8 = 0;
- if (var3 < this.m_width) {
- var5 = this.m_width / var3 + 1;
- }
-
- if (var4 < this.m_height) {
- var6 = this.m_height / var4 + 1;
- }
-
- for(int var9 = var5; var6 > 0; --var6) {
- while(var5 > 0) {
- var1.drawImage(this.m_BackImg, var7, var8, var3, var4, (ImageObserver)null);
- var7 += var3;
- --var5;
- }
-
- var8 += var4;
- var7 = 0;
- var5 = var9;
- }
-
- }
- }
-
- public void start() {
- this.m_stopCalled = false;
- if (this.m_colada == null) {
- this.m_colada = new Thread(this);
- this.m_colada.start();
- }
-
- if (this.m_drawEngThread != null) {
- this.m_drawEngThread.start();
- } else if (this.m_colDoc != null) {
- this.drawEng = new DrawEng(this, this.m_colDoc);
- ++this.field_0;
- this.m_drawEngThread = new Thread(this.drawEng);
- this.m_drawEngThread.start();
- }
-
- ((Component)this).repaint();
- }
-
- public void SetLayerVisability(float var1, int var2) {
- boolean var4 = var2 > 0;
- int var5 = (int)var1;
- if (var5 < this.numlayers) {
- char[] var3 = this.layerFlags.toCharArray();
- if (var4) {
- var3[var5] = 'V';
- ((Applet)this).showStatus("Showing Layer " + var5);
- } else {
- var3[var5] = 'H';
- ((Applet)this).showStatus("Hidding Layer " + var5);
- }
-
- this.layerFlags = new String(var3);
- }
-
- ((Component)this).requestFocus();
- ((Component)this).repaint();
- }
-
- public int abs(int var1) {
- if (var1 < 0) {
- var1 *= -1;
- }
-
- return var1;
- }
-
- public void run() {
- this.m_cvFile = ((Applet)this).getParameter("cvwFile");
- this.m_cvFilePath = ((Applet)this).getParameter("cvwPath");
- this.m_bgTexture = ((Applet)this).getParameter("bgTexture");
- this.m_targetFrame = ((Applet)this).getParameter("targetFrame");
- if (this.m_cvFilePath == null) {
- this.m_cvFilePath = new String(((Applet)this).getCodeBase().toString());
- }
-
- if (this.m_bgTexture != null) {
- this.tracker = new MediaTracker(this);
-
- try {
- this.m_BackImg = this.fetchImageAndWait(new URL(this.m_cvFilePath + this.m_bgTexture), 10);
- } catch (Exception var5) {
- this.m_BackImg = null;
- ((Applet)this).showStatus("BackGround Load Error..");
- }
-
- if (this.tracker.isErrorID(10)) {
- this.m_BackImg = null;
- }
-
- this.tracker = null;
- }
-
- while(this.m_comp != null && !(this.m_comp instanceof Frame)) {
- this.m_comp = this.m_comp.getParent();
- }
-
- try {
- ((Applet)this).showStatus("Downloading file, Please wait... 0% Done");
- this.m_width = ((Component)this).size().width;
- this.m_height = ((Component)this).size().height;
- this.m_colDoc = new ColadaDoc(this, new URL(this.m_cvFilePath + this.m_cvFile));
- this.m_colDocThread = new Thread(this.m_colDoc);
- this.m_colDocThread.start();
- } catch (Exception var4) {
- ((Applet)this).showStatus("Error: " + "run Col. " + ((Throwable)var4).getMessage() + " occured while Downloading.");
- this.stop();
- }
-
- if (this.drawEng == null) {
- try {
- this.drawEng = new DrawEng(this, this.m_colDoc);
- ++this.field_0;
- this.m_drawEngThread = new Thread(this.drawEng);
- this.m_drawEngThread.start();
- } catch (Exception var3) {
- ((Applet)this).showStatus("Error: " + "DrawEng Thread " + ((Throwable)var3).getMessage() + " occured while Downloading.");
- }
- }
-
- ((Component)this).requestFocus();
- ((Component)this).repaint();
- }
-
- public void SetPan(float var1, float var2) {
- int var3 = (int)var1;
- int var4 = (int)var2;
- this.m_colDoc.m_colGraphicObj.m_xOrg = (float)var3;
- this.m_colDoc.m_colGraphicObj.m_yOrg = (float)var4;
- if (this.drawEng.inDrawAll) {
- this.m_breakDrawAll = true;
- }
-
- ((Component)this).repaint();
- }
-
- Image fetchImageAndWait(URL var1, int var2) throws InterruptedException {
- Image var3 = ((Applet)this).getImage(var1);
- this.tracker.addImage(var3, var2);
- this.tracker.waitForID(var2);
- return var3;
- }
-
- public boolean handleEvent(Event var1) {
- boolean var2 = false;
- if (this.m_urlLstDone) {
- switch (var1.id) {
- case 401:
- case 403:
- switch (var1.key) {
- case 27:
- if (!this.m_dloadStoped) {
- this.m_dloadStoped = true;
- this.m_colDocThread.suspend();
- ((Applet)this).showStatus("Download Suspended...");
- if (!this.m_colDocDone) {
- this.m_colDocDone = true;
- }
- } else {
- this.m_dloadStoped = false;
- this.m_colDocThread.resume();
- }
- break;
- case 43:
- case 61:
- if (this.m_colDocDone) {
- if (this.drawEng.inDrawAll) {
- this.m_breakDrawAll = true;
- }
-
- this.m_colDoc.m_colGraphicObj.colZoom(0.25F);
- ((Component)this).repaint();
- }
-
- var2 = true;
- break;
- case 45:
- case 95:
- if (this.m_colDocDone) {
- if (this.drawEng.inDrawAll) {
- this.m_breakDrawAll = true;
- }
-
- this.m_colDoc.m_colGraphicObj.colZoom(-0.25F);
- ((Component)this).repaint();
- }
-
- var2 = true;
- break;
- case 1000:
- if (this.m_colDocDone) {
- this.m_colDoc.m_colGraphicObj.colZoom(0.0F);
- if (this.drawEng.inDrawAll) {
- this.m_breakDrawAll = true;
- }
-
- ((Component)this).repaint();
- }
-
- var2 = true;
- }
- case 504:
- ((Component)this).requestFocus();
- ((Frame)this.m_comp).setCursor(0);
- var2 = true;
- break;
- case 502:
- this.SendEventToObjType(var1, 13, 16, -1, 14);
- if (this.m_panOn) {
- this.m_colDoc.m_colGraphicObj.panOff();
- if (this.m_panOn) {
- if (this.drawEng.inDrawAll) {
- this.m_breakDrawAll = true;
- }
-
- ((Component)this).repaint();
- }
-
- this.m_panOn = false;
- }
-
- this.m_upOrDwn = true;
- case 501:
- this.mPosXdn = var1.x;
- this.mPosYdn = var1.y;
- case 503:
- this.SendEventToObjType(var1, 13, 0, -1, 0);
- this.m_upOrDwn = false;
- this.m_check = false;
-
- for(this.m_curObj = (ColUrl)this.m_colDoc.m_urlLstTail; this.m_curObj != null; this.m_curObj = (ColUrl)this.m_curObj.getPrev()) {
- if (this.m_curObj.m_poly.inside(var1.x, var1.y)) {
- if (var1.id == 502) {
- if (!this.m_curObj.m_url.regionMatches(true, 0, "mailto:", 0, 7) && !this.m_curObj.m_url.regionMatches(true, 0, "ftp", 0, 3) && !this.m_curObj.m_url.regionMatches(true, 0, "Http", 0, 4) && !this.m_curObj.m_url.regionMatches(true, 0, "www", 0, 3) && !this.m_curObj.m_url.regionMatches(true, this.m_curObj.m_url.length() - 3, "htm", 0, 3) && !this.m_curObj.m_url.regionMatches(true, this.m_curObj.m_url.length() - 4, "html", 0, 4)) {
- if (this.m_curObj.m_url.regionMatches(true, 0, "Play:", 0, 5) || this.m_curObj.m_url.regionMatches(true, 0, "Sound On:", 0, 9) || this.m_curObj.m_url.regionMatches(true, 0, "Sound Off:", 0, 10)) {
- int var10 = this.m_curObj.m_url.lastIndexOf(58);
- Long var4 = new Long(this.m_curObj.m_url.substring(var10 + 1));
- if (this.m_curObj.m_url.regionMatches(true, 0, "Sound Off:", 0, 10)) {
- var1.key = 6969;
- } else if (this.m_curObj.m_url.regionMatches(true, 0, "Sound On:", 0, 9)) {
- var1.key = 6970;
- } else {
- var1.key = 6971;
- }
-
- this.SendEventToObjType(var1, 0, 0, var4.intValue(), 0);
- Object var11 = null;
- }
- } else {
- try {
- ((Applet)this).showStatus(this.m_status = "connecting to " + this.m_curObj.m_url);
- if (this.m_targetFrame == null) {
- ((Applet)this).getAppletContext().showDocument(new URL(this.m_curObj.m_url));
- } else {
- ((Applet)this).getAppletContext().showDocument(new URL(this.m_curObj.m_url), this.m_targetFrame);
- }
- break;
- } catch (MalformedURLException var6) {
- ((Applet)this).showStatus("Bad URL " + "EventMouseMove " + ((Throwable)var6).getMessage());
- }
- }
- } else if (this.m_status.indexOf(this.m_curObj.m_url) < 0) {
- ((Frame)this.m_comp).setCursor(12);
- if (this.m_curObj.m_url.regionMatches(true, 0, "mailto:", 0, 7)) {
- ((Applet)this).showStatus(this.m_status = "Sends mail to " + this.m_curObj.m_url.substring(this.m_curObj.m_url.indexOf(":") + 1));
- } else if (!this.m_curObj.m_url.regionMatches(true, 0, "note:", 0, 5) && !this.m_curObj.m_url.regionMatches(true, 0, "Snd:", 0, 4)) {
- ((Applet)this).showStatus(this.m_status = "Shortcut to " + this.m_curObj.m_url);
- }
- }
-
- this.m_check = true;
- break;
- }
- }
-
- if (!this.m_check && this.m_status != "Done") {
- ((Frame)this.m_comp).setCursor(0);
- ((Applet)this).showStatus(this.m_status = "Done");
- }
-
- var2 = false;
- break;
- case 505:
- if (this.m_status != "Done") {
- ((Applet)this).showStatus(this.m_status = "Done");
- }
-
- this.SendEventToObjType(var1, 13, 0, -1, 0);
- var2 = true;
- break;
- case 506:
- if (this.buttonisDn) {
- this.SendEventToObjType(var1, 13, 0, -1, 0);
- } else if (((Component)this).inside(var1.x, var1.y) && (this.abs(this.mPosXdn - var1.x) > 3 || this.abs(this.mPosYdn - var1.y) > 3)) {
- if (!this.m_panOn) {
- this.m_colDoc.m_colGraphicObj.panOn(var1.x, var1.y);
- this.m_panOn = true;
- }
-
- if (this.m_panOn) {
- Graphics var3 = ((Component)this).getGraphics();
- this.m_colDoc.m_colGraphicObj.panDrw(var1.x, var1.y);
- var3.setColor(this.m_colDoc.m_colGraphicObj.m_bkGrndClr);
- var3.fillRect(0, 0, 200, 18);
- var3.setColor(new Color(255 - this.m_colDoc.m_colGraphicObj.m_bkGrndClr.getRed(), 255 - this.m_colDoc.m_colGraphicObj.m_bkGrndClr.getGreen(), 255 - this.m_colDoc.m_colGraphicObj.m_bkGrndClr.getBlue()));
- var3.drawString("Delta X = " + (var1.x - this.mPosXdn) + " Delta Y = " + (var1.y - this.mPosYdn), 10, 10);
- }
- } else if (this.m_panOn) {
- this.m_colDoc.m_colGraphicObj.panOff();
- this.m_panOn = false;
- }
-
- var2 = true;
- }
- }
-
- if (!var2) {
- var2 = super.handleEvent(var1);
- }
-
- return var2;
- }
-
- public void NewCVW(String var1) {
- if (this.m_colDocThread != null) {
- this.m_colDoc.finalize();
- this.m_curObj = null;
- this.m_colDocThread.stop();
- this.m_colDocThread = null;
- }
-
- this.mediaObs = null;
- this.numMediaObjs = 0;
- this.didNew = false;
- this.m_colUpdtEnable = false;
- this.firstDrawDone = false;
- this.m_cvFile = var1;
-
- try {
- ((Applet)this).showStatus("Downloading\tfile, Please wait... 0% Done");
- this.m_width = ((Component)this).size().width;
- this.m_height = ((Component)this).size().height;
- ((Component)this).requestFocus();
- this.m_colDoc = new ColadaDoc(this, new URL(this.m_cvFilePath + this.m_cvFile));
- this.m_colDocThread = new Thread(this.m_colDoc);
- this.m_colDocThread.start();
- } catch (Exception var4) {
- ((Applet)this).showStatus("Error: " + " NewCVW " + ((Throwable)var4).getMessage() + " occured while Downloading.");
- this.stop();
- }
-
- this.drawEng.m_theDoc = this.m_colDoc;
- ((Component)this).repaint();
- }
- }
-